<?php

class Country_Widget_HeadlinenewsController extends Engine_Content_Widget_Abstract
{
  public function indexAction()
  {
	     // Don't render this if not authorized
    $this->view->viewer = $viewer = Engine_Api::_()->user()->getViewer();
    if( !Engine_Api::_()->core()->hasSubject() ) {
      return $this->setNoRender();
    }
    // Get subject and check auth
    $this->view->subject = $subject = Engine_Api::_()->core()->getSubject('country');	

    // Prepare data
    $newsTable = Engine_Api::_()->getDbtable('news', 'country');
    $values['country']  = $subject->getIdentity();
    // Get paginator
    $this->view->paginator = $paginator = Engine_Api::_()->getItemTable('country_news')->getNewsPaginator($values);
    $items_per_page = 15;
    $paginator->setItemCountPerPage($items_per_page);
    $this->view->paginator = $paginator->setCurrentPageNumber(1);

    $this->view->canCreate = Engine_Api::_()->getDbTable('Managers', 'Country')->isManager($values['country'], $viewer->getIdentity());
  }
}
